import java.util.ArrayList;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: happyiu
 * Date: 2022-03-01
 * Time: 8:45
 * Description:
 */

/*class MyArrayList{
    private int[] elem;
    private int useSize;
    public MyArrayList(){
        this.elem = new int[10];
    }
    public void add(int val){
        this.elem[useSize] = val;
        useSize++;
    }
    public int get(int pos){
        return this.elem[pos];
    }
}*/

/*class MyArrayList{
    private Object[] elem;
    private int useSize;
    public MyArrayList(){
        this.elem = new Object[10];
    }
    public void add(Object val){
        this.elem[useSize] = val;
        useSize++;
    }
    public Object get(int pos){
        return this.elem[pos];
    }
}*/

class MyArrayList<E>{
    private E[] elem;
    private int useSize;
    public MyArrayList(){
        this.elem = (E[])new Object[10];
    }
    public void add(E val){
        this.elem[useSize] = val;
        useSize++;
    }
    public E get(int pos){
        return this.elem[pos];
    }
}


public class TestDemo {
    /*public static void main1(String[] args) {
        MyArrayList myArrayList = new MyArrayList();
        myArrayList.add(10);
        myArrayList.add("kkk");
    }

    public static void main(String[] args) {
        MyArrayList myArrayList = new MyArrayList();
        myArrayList.add(10);
        myArrayList.add("kkk");
        String ret = (String)myArrayList.get(1);
        System.out.println(ret);
    }*/

    public static void main1(String[] args) {
        MyArrayList<Integer> myArrayList1 = new MyArrayList();
        myArrayList1.add(123);
        myArrayList1.add(456);
        int ret = myArrayList1.get(1);
        System.out.println(ret);

        MyArrayList<String> myArrayList2 = new MyArrayList<>();
        myArrayList2.add("abc");
        myArrayList2.add("happy");
        System.out.println(myArrayList2.get(1));

        MyArrayList<Boolean> myArrayList3 = new MyArrayList<>();
        myArrayList3.add(true);
        myArrayList3.add(false);

    }

        public static void main2(String[] args) {
            MyArrayList<Integer> myArrayList1 = new MyArrayList();
            MyArrayList<String> myArrayList2 = new MyArrayList<>();
            MyArrayList<Boolean> myArrayList3 = new MyArrayList<>();

            System.out.println(myArrayList1);
            System.out.println(myArrayList2);
            System.out.println(myArrayList3);

        }

    public static void main(String[] args) {
        List<String> list = new ArrayList<>();
    }

}
